#pragma once

#include <iostream>
#include <stdint.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <cerrno>
#include <cstring>
#include "log.hpp"

class UdpServer
{
public:
    UdpServer(uint16_t port, const std::string ip =" ")
    :_port(port)
    ,_ip(ip)
    ,_sock(-1)
    { }

    void initServer()
    {
        // 这里来完成网络功能
        _sock = socket(AF_INET, SOCK_DGRAM, 0);
        if(_sock < 0)
        {
            logMessage(FATAL, "%s : %s", errno, strerror(errno));
            LogPrint(FATAL, "socket create false...");
            exit(2);
        }
    }

    void start()
    {

    }

    ~UdpServer()
    {

    }



private:
    int _sock;
    std::uint16_t _port;
    std::string _ip;

};